home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / dl_mac.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  138 lines

  1. ; $Id: dl_mac.pro,v 1.4 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1994-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5. ;
  6.  
  7. pro doc_file, name, outunit     ; print documentation for file 'name'
  8.   printf, outunit
  9.   printf, outunit, '----- Documentation for ',name
  10.   printf, outunit
  11.  
  12.   openr, unit, name, /GET_LUN
  13.  
  14.   line = ""
  15.   outflag = 0
  16.   readf, unit, line
  17.   while not eof(unit) and strpos(line, ";-") ne 0 do begin
  18.     if outflag then $
  19.       printf, outunit, strmid(line, 1, 132)
  20.  
  21.     ; output lines after line which starts with ";+"
  22.     if strpos(line, ";+") eq 0 then $
  23.       outflag = 1
  24.     readf, unit, line
  25.   endwhile
  26.  
  27.   close, unit
  28. end
  29.  
  30. pro DL_MAC, NAME, PRINT=printflag, DIRECTORY = direct
  31.  
  32. ;+NODOCUMENT
  33. ; NAME:
  34. ;    DL_MAC
  35. ;
  36. ; PURPOSE:
  37. ;    Extract the documentation template of one or more procedures (Macintosh
  38. ;    version).
  39. ;
  40. ; CATEGORY:
  41. ;    Help, documentation.
  42. ;
  43. ; CALLING SEQUENCE:
  44. ;    DL_MAC        ;For prompting.
  45. ;    DL_MAC, Name     ;Extract documentation for procedure Name using
  46. ;                the current !PATH.
  47. ;
  48. ; INPUTS:
  49. ;    Name:    A string containing the name of the procedure or "*" for all.
  50. ;
  51. ; OPTIONAL INPUT PARAMETERS:
  52. ;
  53. ;   DIRECTORY:    The directory to search.  If omitted, the current directory
  54. ;        and !PATH are used.
  55. ;
  56. ;       PRINT:  Name of a file to print to.
  57. ;
  58. ; OUTPUTS:
  59. ;    No explicit outputs.  Documentation is output using 'more' format 
  60. ;    unless /PRINT is specified.
  61. ;
  62. ; COMMON BLOCKS:
  63. ;    None.
  64. ;
  65. ; SIDE EFFECTS:
  66. ;    Output is produced on terminal or to a file.  If the current directory
  67. ;    is also one of the directories specified in !PATH or DIRECTORY,
  68. ;    documentation will be output twice for the specified module(s).
  69. ;
  70. ; RESTRICTIONS:
  71. ;    ??
  72. ;
  73. ; PROCEDURE:
  74. ;    Straightforward.
  75. ;
  76. ; MODIFICATION HISTORY:
  77. ;    DJE, 14 Nov 1994, adapted from DL_DOS.PRO
  78. ;-
  79.  
  80.   on_error,2                            ;Return to caller if an error occurs
  81.  
  82.   ;Interactive query?
  83.   if n_elements(name) eq 0 then begin
  84.     name = ''
  85.     read, 'Name of procedure or * for all: ',name
  86.   endif
  87.  
  88.   name = strlowcase(name)               ;make it always lower case
  89.  
  90.   ;
  91.   ; if DIRECTORY not specified, use !path
  92.   ;
  93.   if n_elements(direct) eq 0 then begin
  94.     cd, current=curr
  95.  
  96.     ; add the current directory to the search path if it is not already there 
  97.     if strpos(!path, curr) eq -1 then $
  98.       path = curr + "," + !path $
  99.     else $
  100.       path = !path
  101.   endif else begin
  102.     path = direct                       ; otherwise use DIRECTORY 
  103.   endelse
  104.  
  105.   ;
  106.   ; output always goes to the log window
  107.   ;
  108.   outunit=-1
  109.   if n_elements(printflag) ne 0 then $
  110.     openw, outunit, printflag, /GET_LUN
  111.  
  112.   ;
  113.   ; loop for every directory in path
  114.   ;
  115.   while strlen(path) gt 0 do begin ; Find it
  116.     i = strpos(path, ",")
  117.     if i lt 0 then i = strlen(path)
  118.     name_path = strmid(path, 0, i)
  119.     cd, name_path
  120.  
  121.     ;
  122.     ;  file_list contains all file(s) to document
  123.     ;
  124.     file_list = findfile(name_path + name + '.pro', count=n_files)
  125.     ; document every file
  126.     for n = 0, n_files-1 do begin
  127.       doc_file, file_list[n], outunit
  128.       printf, outunit
  129.     endfor
  130.     path = strmid(path, i + 1, 1000)
  131.   endwhile
  132.  
  133.   if n_elements(printflag) ne 0 then $
  134.     free_lun, outunit
  135.   cd, curr
  136.  
  137. end
  138.